package com.blue.tooth.lock.util;

import android.content.Context;
import android.util.Log;

public class DebugLogUtil {

    // 单例访问
    private static DebugLogUtil debugUtil;
    /**
     * 判断是否在进行Debug开发阶段, 默认false
     */
    private boolean isDebug;
    /**
     * 打印日志过滤标示，默认'Application'
     */
    private String Filter;

    private DebugLogUtil() {
        isDebug = isDebug();
        Filter = "zhuochuang";
    }

    private String commonMsg = "";

    /**
     * 创建该类对象唯一的方法
     *
     * @return
     */
    public static DebugLogUtil getInstance() {
        if (debugUtil == null) {
            synchronized (DebugLogUtil.class) {
                if (debugUtil == null) {
                    debugUtil = new DebugLogUtil();
                }
            }
        }
        return debugUtil;
    }

    public boolean isDebug() {
        return true;
    }

    public void setDebug(boolean isDebug) {
        this.isDebug = isDebug;
    }

    public String getFilter() {
        return Filter;
    }

    public void setFilter(String filter) {
        Filter = filter;
    }

    public void Verbose(String logCat) {
        if (isDebug) {
            Log.v(this.Filter, commonMsg + logCat);
        }
    }

    public void Debug(String logCat) {
        if (isDebug) {
            Log.d(this.Filter, commonMsg + logCat);
        }
    }

    public void Info(String logCat) {
        if (isDebug) {
            Log.i(this.Filter, commonMsg + logCat);
        }
    }

    public void Warn(String logCat) {
        if (isDebug) {
            Log.w(this.Filter, commonMsg + logCat);
        }
    }

    public void Error(Context context, String logCat) {
        if (isDebug && context != null) {
            Log.e(this.Filter, context.getClass() + logCat);
        }
    }
}
